<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
	include '../../connection/connection.php';	
	include '../../value/value_kr.php';
	
	$username = $_REQUEST['username'];
	$depart = $_REQUEST['depart'];
	$homephone = $_REQUEST['homephone'];
	$telphone = $_REQUEST['telphone'];
	$passw = $_REQUEST['passw'];
	$roleuser = $_REQUEST['roleuser'];
	$ipuser = $_REQUEST['ipuser'];
	$winH = $_REQUEST['winH'];
	
	$insertuser =mysql_query("insert into caruser(szUser,szTeam,szPhone,szMobile,szPasswd,szPower,szIP) 
	  	values('".$username."','".$depart."','".$homephone."','".$telphone."','".$passw."','".$roleuser."','".$ipuser."')",$connection);
	 
	$list=$_SESSION['sort'];
	if(!isset($_REQUEST['page'])){
		$list["cars.szUser"]="DESC";
		$list["cars.szTeam"]="DESC";
		$list["cars.szPhone"]="DESC";
		$list["cars.szMobile"]="DESC";
		$list["cars.szPower"]="DESC";
		$list["cars.szIP"]="DESC";

		$str="cars.szUser";
		
		$_SESSION['sortn']=$str;
		$_SESSION['sort']=$list;
	}else{
		$str=$_SESSION['sortn'];
		$list=$_SESSION['sort'];
	}
	$sql = "SELECT cars.* from caruser cars";
	$selectuser = mysql_query($sql." ORDER BY ".$str." ".$list[$str],$connection);
	$_SESSION['sort']=$list;
?>
 <div style="overflow:scroll;overflow-x: hidden; width:100%; height:<?php echo ($winH-240)."px"?>; background-color: #ffffff">
	        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" id="tablebody2">
	            <tbody>
	            <?php
	            	$i = 0;
	             while ($rowus = mysql_fetch_array($selectuser)) {
	             	$i++;?>
		            <tr id="idrowuser" onclick="onclickRowUser(this,<?=$rowus[iUser]?>)">
		            	<td style="width: 5%"><?=$i?></td>
		                <td style="width: 25%"><?=$rowus[szUser]."&nbsp;"?></td>
		                <td style="width: 15%"><?=$rowus[szTeam]."&nbsp;"?></td>
		                <td style="width: 13.75%"><?=$rowus[szPhone]."&nbsp;"?></td>
		                <td style="width: 13.75%"><?=$rowus[szMobile]."&nbsp;"?></td>
		                <td style="width: 13.75%"><?=$rowus[szPower]."&nbsp;"?></td>
		                <td class="last" style="width: 13.75%;border-right: none !important;"><?=$rowus[szIP]?></td>
		            </tr>
	              <?php
	                		 }
						if ($i>0 and $i<($winH/28)) {
							 	foreach(range(0,intval($winH/28)-$i) as $real){
							 		?>
							 		<tr>
							 			<td width="5%">&nbsp;</td>
								 		<td width="25%">&nbsp;</td>
								 		<td width="15%">&nbsp;</td>
								 		<td width="13.75%">&nbsp;</td>
								 		<td width="13.75%">&nbsp;</td>
									 	<td width="13.75%">&nbsp;</td>
									 	<td class="last" style="width: 13.75%;border-right: none !important;">&nbsp;</td>
								 	</tr>
							 	<?php }
							}?>
	            </tbody>              
	        </table>
	        </div>
             <?php mysql_close($connection);?>